(function(Game){

    function Bird(option){
        this.ctx=option.ctx;//画布
        this.x=option.x||100;
        this.y=option.y||100;
        this.img=option.img;
        this.width=this.img.width/3;
        this.height=this.img.height;

        //加速运动的数据
        this.a=0.0005;
        this.speed=0;
        this.maxSpeed=0.5;
        this.angle=0;
        this.maxAngle=45;
        this.index=0;//当前第几帧
    }
    //行为
    Bird.prototype.render=function(Dvalue){
        this.speed=this.speed+this.a*Dvalue; //求出当前速度
        if(this.speed>this.maxSpeed){
            this.speed=this.maxSpeed;
        }
        this.y=this.y+this.speed*Dvalue+1/2*this.a*Dvalue*Dvalue; //求出当前
        this.angle=this.speed/this.maxSpeed*this.maxAngle; //求出当前角度

        this.ctx.save();
        this.ctx.translate(this.x,this.y);
        this.ctx.rotate(this.angle*Math.PI/180);
        this.ctx.drawImage(this.img,this.index*this.width,0,this.width,this.height,-this.width/2,-this.height/2,this.width,this.height);

        this.ctx.restore();

        this.index++;
        this.index%=3;//0 1 2

    }

    Game.Bird=Bird;

})(Game);
